import rxAjax from '@/assets/js/ajax.js';
import { TokenUtil } from '@lowcode/jpaas-base-lib'

const ResourceApi = {};

ResourceApi.baseUrl= '/api-user/user/org/menu';

/**
 * 获取前端应用列表.
 * @returns {*}
 */
ResourceApi.getFrontApps=function(){
    let url = ResourceApi.baseUrl + '/getFrontApps';
    return rxAjax.get(url);
}

/**
 * 根据应用key获取应用，菜单按钮，全部按钮.
 * @param appId
 * @param appKey
 * @returns {*}
 */
ResourceApi.getFrontByAppKey=function({appId,appKey}){
    let key = '';
    if(appId){
        key = `appId=${appId}`
    }else if(appKey){
        key = `appKey=${appKey}`
    }
    let url = ResourceApi.baseUrl + `/getFrontApp?${key}`;
    return rxAjax.get(url);
}

/**
 * 根据当前的token获取当前登录人员信息
 * @returns {*}
 */
ResourceApi.getCurUser = function () {
    let token = TokenUtil.getToken();
    return rxAjax.postForm(`/api-uaa/oauth/user/current`,{token})
}

export  default ResourceApi;

